#!/usr/bin/env python
# -*- coding: utf-8 -*-

import erppeek

ODOO_HOST = 'http://localhost:8069'
ODOO_DB = 'demo_sg'
ODOO_API_USERNAME = 'admin'
ODOO_API_PASSWORD = 'admin'

# 免登陆时使用的单件模式odoo client
class Client(object):
   instance = None
   @staticmethod
   def getInstance():
     import threading
     #线程安全
     mylock = threading.RLock()
     mylock.acquire()
     if not Client.instance:
       Client.instance = erppeek.Client(ODOO_HOST, ODOO_DB, ODOO_API_USERNAME, ODOO_API_PASSWORD)
     mylock.release()

     return Client.instance